package org.mad.code.util;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.InvalidPropertiesFormatException;
import java.util.Properties;

/**
 * Manager of the application properties. 
 * @author E420611
 *
 */
public class PropertiesManager {

	private static Properties props;

	static {
		loadProperties();

	}


	private static void loadProperties() {
		// Reading properties file in Java example
		props = new Properties();
		FileInputStream fis;
		try {
			fis = new FileInputStream(Messages.PropertiesManager_PropertyPath);

			props.loadFromXML(fis);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvalidPropertiesFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		// reading proeprty
//		String username = props.getProperty(Messages.PropertiesManager_1);
//		System.out.println(Messages.PropertiesManager_2 + username);
	}


	/**
	 * Get a property.
	 * 
	 * @param prop
	 * @return
	 */
	public static String getProperty(String prop){
		loadProperties();
		return props.getProperty(prop);
	}
}
